import axios from 'axios';
// 列表
export function getSingerList() {
  const url = '/api/getSingerList'

  const data = Object.assign({}, {
    callback: getUCGI7399274485328875(),
    g_tk: 775357807,
    jsonpCallback: getUCGI7399274485328875(),
    loginUin: 0,
    hostUin: 0,
    format: 'jsonp',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq',
    needNewCode: 0,
    data: {
      "comm": {
        "ct": 24,
        "cv": 10000
      },
      "singerList": {
        "module": "Music.SingerListServer",
        "method": "get_singer_list",
        "param": {
          "area": -100,
          "sex": -100,
          "genre": -100,
          "index": -100,
          "sin": 0,
          "cur_page": 1
        }
      }
    }
  })

  function getUCGI7399274485328875() {}

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 详情
export function getSingerDetaill(id) {
  const url = '/api/getSingerDetaill'

  const data = Object.assign({}, {
    g_tk: 775357807,
    jsonpCallback: MusicJsonCallbacksinger_track(),
    loginUin: 0,
    hostUin: 0,
    format: 'jsonp',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq',
    needNewCode: 0,
    singermid: id,
    order: 'listen',
    begin: 0,
    num: 30,
    songstatus: 1
  })

  function MusicJsonCallbacksinger_track() {}

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 歌曲链接

export function getSingerUrl(id) {
  const url = '/api/getSingerUrl'

  const data = Object.assign({}, {
    g_tk: 5381,
    jsonpCallback: MusicJsonCallback9597603970413269(),
    loginUin: 0,
    hostUin: 0,
    format: 'json',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq',
    needNewCode: 0,
    cid: 205361747,
    callback: MusicJsonCallback9597603970413269(),
    uin: 0,
    songmid: id,//'000YU69H3N55rZ'
    filename: `C400${id}.m4a`,//'',
    guid: 6013807710,
  })

  function MusicJsonCallback9597603970413269() {}

  return axios.get(url, {
    params: data
  }).then((res) => {
    // return Promise.resolve(res.data)
    const mussic = res.data.data.items["0"]
    return  Promise.resolve(`http://dl.stream.qqmusic.qq.com/${mussic.filename}?vkey=${mussic.vkey}&guid=6013807710&uin=0&fromtag=66`)
  })
}
